const CheckUtils = require('./CheckUtils.jsx');

const fn = {
    getRoutePath(routes, parentPath, breadCrumbMap) {
        if(!routes) {
            return;
        }
        routes = CheckUtils.isArray(routes) ? routes : [routes];
        routes.forEach(v => {
            const { path, name, children } = v.props;
            const _path = (parentPath === '/' ? '' : parentPath ) + (path ? ('/' + (path === '/' ? '' : path)) : '');
            !CheckUtils.isEmpty(name) ? breadCrumbMap.set(_path, name) : '';
            this.getRoutePath(children, _path, breadCrumbMap);
        });
    }
};

module.exports = fn;